package com.umer.pinban.adapter.home;

import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.common.ui.brvah.BaseQuickAdapter;
import com.common.ui.brvah.BaseViewHolder;
import com.common.utils.screen.DensityUtil;
import com.common.utils.screen.ScreenUtil;
import com.umer.pinban.MainActivity;
import com.umer.pinban.R;
import com.umer.pinban.bean.home.HomeBean;

import java.util.List;

public class HomeAdapter extends BaseQuickAdapter<HomeBean, BaseViewHolder> {

    public HomeAdapter(int layoutResId, @Nullable List<HomeBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, HomeBean item) {

        ImageView imageView = helper.getView(R.id.iv);
       /* int height = ScreenUtil.getInstance().getScreenHeight() -ScreenUtil.getInstance().getStatusBarHeight() -
                ScreenUtil.getInstance().getBottomStatusHeight();*/
        int height = ScreenUtil.getInstance().getScreenWidth();
        int part = (height/8) - DensityUtil.getInstance().dpToPx(40);
        //取控件当前的布局参数
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) imageView.getLayoutParams();
        //设置宽度值
        params.width = part;
        //设置高度值
        params.height = part;
        params.bottomMargin = 15;
        params.topMargin = 5;
       //使设置好的布局参数应用到控件
        imageView.setLayoutParams(params);
        helper.setImageResource(R.id.iv, item.getRes());
    }
}
